﻿@using Ecommerce.Models
@using Library
@model Library.Models.SpecificationGroup
@{
    var modeCulture = Model.SpecificationGroupCultures.SingleOrDefault(pcc => pcc.Culture == NOWCulture.CurrentCulture) ?? Model.SpecificationGroupCultures.First();
    var specifications = Model.Specifications.OrderBy(i => i.DisplayOrder);

    var productSpecifications = ViewData["productSpecifications"] as ProductViewModel.ProductSpecification[];
}
<tr class="warning">
    <th scope="row">@Html.DisplayFor(m => modeCulture.Name)</th>
    <td>&nbsp;</td>
</tr>
@foreach (var specification in specifications)
{
    var selectedValue = productSpecifications == null ? null : productSpecifications.SingleOrDefault(i => i.SpecificationId == specification.Id);

    if (selectedValue != null)
    {
        @Html.Partial("_ProductSpecificationRow", specification, new ViewDataDictionary()
        {
            new KeyValuePair<string, object>("selectedValue", selectedValue.SpecificationValueId)
        })
    }
    else
    {
        @Html.Partial("_ProductSpecificationRow", specification)
    }
}